package lesson01;

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class ExDemo {

    public static void main(String[] args) {
    Frame frame=new Frame();
    frame.setLayout(new GridLayout(2,2));
    //4个面板
    Panel panel1=new Panel(new BorderLayout());
    Panel panel2=new Panel(new GridLayout(2,1));
    Panel panel3=new Panel(new BorderLayout());
    Panel panel4=new Panel(new GridLayout(2,2));
      //初始化
        frame.setVisible(true);
//        frame.pack();
        frame.setBounds(500,500,500,500);
//        frame.setResizable(false);
        frame.setBackground(Color.blue);


    Button east1=new Button("east1");
    Button west1=new Button("west1");
    panel1.add(east1,BorderLayout.EAST);
    panel1.add(west1,BorderLayout.WEST);
    Button center1=new Button();
    Button center2=new Button();
    panel2.add(center1);
    panel2.add(center2);
    panel1.add(panel2,BorderLayout.CENTER);

        frame.add(panel1);

        Button east2=new Button("east2");
        Button west2=new Button("west2");
        panel3.add(east2,BorderLayout.EAST);
        panel3.add(west2,BorderLayout.WEST);
        for(int i=1;i<=4;i++)
        { panel4.add(new Button("btn"+i));
        }
        panel3.add(panel4,BorderLayout.CENTER);


    frame.add(panel3);

    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });


    }
}
